<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="model.*"%>
<%
	QuotationModel obj;
	Object temp = request.getAttribute("document");
	if (temp != null) {
		try {
			obj = (QuotationModel) temp;
		} catch (Exception ex) {
			obj = new QuotationModel();
		}
	} else {
		obj = new QuotationModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Quotation</title>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<link rel="stylesheet" href="css/datepicker.css" />
<link rel="stylesheet" href="css/common.css" />
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.6.1.min.js"></script>

<script language="javascript" type="text/javascript">
	var requiredInputs = [['id_ref','id_ref_required'],['id_project','id_project_required'],['name','name_required'],['code','code_required'],['description','description_required'],['id_author','id_author_required'],['id_approver','id_approver_required'],['issue_date','issue_date_date_required', 'issue_date','issue_date_time_required'],['remark','remark_required'],['id_currency','id_currency_required'],['total','total_required'],['management_fee','management_fee_required'],['vat_rate','vat_rate_required'],['grand_total','grand_total_required'],['id_type','id_type_required'],['status','status_required'],['notification','notification_required']];
	var intInputs = [['id_ref','id_ref_invalid'],['id_project','id_project_invalid'],['id_author','id_author_invalid'],['id_approver','id_approver_invalid'],['id_currency','id_currency_invalid'],['id_type','id_type_invalid'],['status','status_invalid'],['notification','notification_invalid']];
	var doubleInputs = [['total','total_invalid'],['management_fee','management_fee_invalid'],['vat_rate','vat_rate_invalid'],['grand_total','grand_total_invalid']];
	var dateInputs = [['issue_date','issue_date_date_invalid']];
	var timeInputs = [['issue_date','issue_date_time_invalid']];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
	<form action="quotation?mode=insert" method="post"
        onSubmit="return checkInputs()"
        onreset="return confirm('Do you really want to reset the form?')">
		<table class="tblInput" border="1">
			<tr class="inputHeader">
				<td colspan="3" class="inputHeader">Create New Quotation</td>
			</tr>
			<tr class="trField">
				<td class="tdFieldName">Id Ref</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_ref" name="id_ref" maxlength="10" value="<%=obj.getIdRef()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_ref_required" class="errMsg" style="display: none;">Id Ref is required</span> 
					<span id="id_ref_invalid" class="errMsg" style="display: none;">Id Ref is invalid</span>
                    <span id="id_ref_error" class="errMsg"><%=obj.errMsgs.IdRef%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Project</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_project" name="id_project" maxlength="10" value="<%=obj.getIdProject()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_project_required" class="errMsg" style="display: none;">Id Project is required</span> 
					<span id="id_project_invalid" class="errMsg" style="display: none;">Id Project is invalid</span>
                    <span id="id_project_error" class="errMsg"><%=obj.errMsgs.IdProject%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Name</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="name" name="name" maxlength="255" value="<%=obj.getName()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="name_required" class="errMsg" style="display: none;">Name is required</span>
					<span id="name_invalid" class="errMsg" style="display: none;">Name is invalid</span>
                    <span id="name_error" class="errMsg"><%=obj.errMsgs.Name%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Code</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="code" name="code" maxlength="20" value="<%=obj.getCode()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="code_required" class="errMsg" style="display: none;">Code is required</span>
					<span id="code_invalid" class="errMsg" style="display: none;">Code is invalid</span>
                    <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Description</td>				    <td class="tdFieldInput">
					<textarea id="description" name="description" rows="5" class="inputTextarea"><%=obj.getDescription()%></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="description_required" class="errMsg" style="display: none;">Description is required</span>
					<span id="description_invalid" class="errMsg" style="display: none;">Description is invalid</span>
                    <span id="description_error" class="errMsg"><%=obj.errMsgs.Description%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Author</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_author" name="id_author" maxlength="10" value="<%=obj.getIdAuthor()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_author_required" class="errMsg" style="display: none;">Id Author is required</span> 
					<span id="id_author_invalid" class="errMsg" style="display: none;">Id Author is invalid</span>
                    <span id="id_author_error" class="errMsg"><%=obj.errMsgs.IdAuthor%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Approver</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_approver" name="id_approver" maxlength="10" value="<%=obj.getIdApprover()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_approver_required" class="errMsg" style="display: none;">Id Approver is required</span> 
					<span id="id_approver_invalid" class="errMsg" style="display: none;">Id Approver is invalid</span>
                    <span id="id_approver_error" class="errMsg"><%=obj.errMsgs.IdApprover%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Issue Date</td>				<td class="tdFieldInput">
					<table class="tblDateTime">
						<tr class="trDateTime">
							<td class="tdDate">
								<input type="text" maxlength="10" class="inputDate" id="issue_date_date" name="issue_date_date" value="<%=obj.getIssueDate()%>" /> 
								<input type="button" class="btnCalendar" value="..."
									onclick="javascript:displayDatePicker('issue_date_date', this, dateFormat);" />
							</td>
							<td class="tdTime">
								<input type="text" maxlength="5" class="inputTime" id="issue_date_time" name="issue_date_time" value="<%=obj.getIssueDate()%>" />
							</td>
						</tr>
					</table></td>
				<td class="tdErrMsg">
                    <span id="issue_date_error" class="errMsg"><%=obj.errMsgs.IssueDate%></span>
					<div class="divErr">
						<span id="issue_date_date_required" class="errMsg"
							style="display: none;">Issue Date's date is required</span>
					</div>
					<div class="divErr">
						<span id="issue_date_time_required" class="errMsg"
							style="display: none;">Issue Date's time is required</span>
					</div>
					<div class="divErr">
						<span id="issue_date_date_invalid" class="errMsg"
							style="display: none;">Issue Date's date is invalid</span>
					</div>
					<div class="divErr">
						<span id="issue_date_time_invalid" class="errMsg"
							style="display: none;">Issue Date's time is invalid</span>
					</div>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Remark</td>				    <td class="tdFieldInput">
					<textarea id="remark" name="remark" rows="5" class="inputTextarea"><%=obj.getRemark()%></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="remark_required" class="errMsg" style="display: none;">Remark is required</span>
					<span id="remark_invalid" class="errMsg" style="display: none;">Remark is invalid</span>
                    <span id="remark_error" class="errMsg"><%=obj.errMsgs.Remark%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Currency</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_currency" name="id_currency" maxlength="10" value="<%=obj.getIdCurrency()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_currency_required" class="errMsg" style="display: none;">Id Currency is required</span> 
					<span id="id_currency_invalid" class="errMsg" style="display: none;">Id Currency is invalid</span>
                    <span id="id_currency_error" class="errMsg"><%=obj.errMsgs.IdCurrency%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Total</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="total" name="total" maxlength="20" value="<%=obj.getTotal()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="total_required" class="errMsg" style="display: none;">Total is required</span> 
					<span id="total_invalid" class="errMsg" style="display: none;">Total is invalid</span>
                    <span id="total_error" class="errMsg"><%=obj.errMsgs.Total%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Management Fee</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="management_fee" name="management_fee" maxlength="20" value="<%=obj.getManagementFee()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="management_fee_required" class="errMsg" style="display: none;">Management Fee is required</span> 
					<span id="management_fee_invalid" class="errMsg" style="display: none;">Management Fee is invalid</span>
                    <span id="management_fee_error" class="errMsg"><%=obj.errMsgs.ManagementFee%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Vat Rate</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="vat_rate" name="vat_rate" maxlength="20" value="<%=obj.getVatRate()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="vat_rate_required" class="errMsg" style="display: none;">Vat Rate is required</span> 
					<span id="vat_rate_invalid" class="errMsg" style="display: none;">Vat Rate is invalid</span>
                    <span id="vat_rate_error" class="errMsg"><%=obj.errMsgs.VatRate%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Grand Total</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="grand_total" name="grand_total" maxlength="20" value="<%=obj.getGrandTotal()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="grand_total_required" class="errMsg" style="display: none;">Grand Total is required</span> 
					<span id="grand_total_invalid" class="errMsg" style="display: none;">Grand Total is invalid</span>
                    <span id="grand_total_error" class="errMsg"><%=obj.errMsgs.GrandTotal%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Type</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_type" name="id_type" maxlength="10" value="<%=obj.getIdType()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_type_required" class="errMsg" style="display: none;">Id Type is required</span> 
					<span id="id_type_invalid" class="errMsg" style="display: none;">Id Type is invalid</span>
                    <span id="id_type_error" class="errMsg"><%=obj.errMsgs.IdType%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Status</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="status" name="status" maxlength="10" value="<%=obj.getStatus()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="status_required" class="errMsg" style="display: none;">Status is required</span> 
					<span id="status_invalid" class="errMsg" style="display: none;">Status is invalid</span>
                    <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Notification</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="notification" name="notification" maxlength="10" value="<%=obj.getNotification()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="notification_required" class="errMsg" style="display: none;">Notification is required</span> 
					<span id="notification_invalid" class="errMsg" style="display: none;">Notification is invalid</span>
                    <span id="notification_error" class="errMsg"><%=obj.errMsgs.Notification%></span>
                </td></tr>
			
			<tr class="trInputBottom">
				<td class="trInputBottom" colspan="3">
					<table class="tblSubmit" align="center">
						<tr class="trSubmit">
							<td class="tdSubmit"><input type="submit" value="Submit" />
							</td>
							<td class="tdReset"><input type="reset" value="Reset" /></td>
						</tr>
					</table></td>
			</tr>
		</table>
	</form>
</body>
</html>